# import pymysql
#
# client = pymysql.connect(
#     port=3306,
#     host='localhost',
#     user='root',
#     password='123456',
#     db='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
#
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()



# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     password='123456',
#     port=3306,
#     charset='utf8',
#     db='hugo'
# )
# cursor = client.cursor()
#
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     password='123456',
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()


# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     password='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1
# '''
#
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     password='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
#
# sql = '''
#     select * from tt1
# '''
# cursor = client.cursor()
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     password='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql= '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql='''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1 where id = 1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql ='''
#     select * from tt1 where id = 3
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1 where id in(1)
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1 where id=3
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

# import pymysql
#
# client = pymysql.connect(
#     host='localhost',
#     user='root',
#     passwd='123456',
#     port=3306,
#     database='hugo',
#     charset='utf8'
# )
# cursor = client.cursor()
# sql = '''
#     select * from tt1 where id=1
# '''
# cursor.execute(sql)
# client.commit()
# print(cursor.fetchall())
# cursor.close()
# client.close()

import pymysql

client = pymysql.connect(
    host='localhost',
    user='root',
    passwd='123456',
    port=3306,
    database='hugo',
    charset='utf8'
)
cursor = client.cursor()
sql = '''
    select * from tt1
'''
try:
    cursor.execute(sql)
    client.commit()
    print('查询成功')
    print(cursor.fetchall())
except Exception as e:
    print('查询错误')

cursor.close()
client.close()
'''
try:
    print('aaa')
    a=2
    cursor.execute(a)
except Exception as e:
    print('错误')
'''
try:
    aaa = 2
    cursor.excute(aaa)
except Exception:
    print('错误')









